import 'package:casdon/modules/me/data/model/browsing_life_history_model.dart';


class BrowsingLifeHistoryState {
  final List<BrowsingLifeHistoryModel> data;
  final int totalSize;

  BrowsingLifeHistoryState({required this.data, required this.totalSize});

  /// 按日期分组的浏览记录
  Map<String, List<BrowsingLifeHistoryModel>> get groupedByDate {
    final Map<String, List<BrowsingLifeHistoryModel>> grouped = {};
    for (final item in data) {
      final date = item.createTime.split(' ').first;
      if (!grouped.containsKey(date)) {
        grouped[date] = [];
      }
      grouped[date]!.add(item);
    }
    // 按日期倒序排列
    final sortedEntries = grouped.entries.toList()
      ..sort((a, b) => b.key.compareTo(a.key));
    return Map.fromEntries(sortedEntries);
  }
}
